package org.andao.core.support.context;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.AbstractApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

/**
 * 用于单元测试的的SpringContext.
 * @author Seewo software - Marco.hu(huzhiguo@cvte.cn)
 */
public class SpringContextForUnitTestHolder {
	
	private static AbstractApplicationContext applicationContext = new ClassPathXmlApplicationContext("spring/test-applicationContext*.xml");
	
	/**
	 * 获取Bean
	 * @param beanName
	 * @return
	 */
	public  Object getBean(String beanName){		
		return applicationContext.getBean(beanName);
	}	
		
	public  ApplicationContext getApplicationContext(){
		return applicationContext;
	}
	
	public  void close(){
		if(null != applicationContext)applicationContext.close();
	}

}
